package com.hwh.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.hwh.serviceIm.SellersServiceImpl;
import com.hwh.vo.Sellers;

public class SellLoginController extends HttpServlet{

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
	         throws ServletException, IOException {
      super.doPost(req, resp);
  }

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		// 获取前台form表单的input输入框
		String sell_name = req.getParameter("sell_name");
		String sell_pwd = req.getParameter("sell_pwd");
		
		Sellers sell = new Sellers();
		sell.setSell_name(sell_name);
		sell.setSell_pwd(sell_pwd);
		SellersServiceImpl ssi = new SellersServiceImpl();
		Sellers s = ssi.sellerLogin(sell);
		HttpSession session = req.getSession();
		session.setAttribute("Sellers", s);
		
		if (s.getSell_name() != null) {
			// 返回的不是空值,重定向到登录成功界面
			
			req.getRequestDispatcher("selindex.jsp").forward(req, resp);
		} else {
			
			req.getRequestDispatcher("sellogin.jsp").forward(req, resp);
		}
	}
	
}
